pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let idx = num_str.find('(').unwrap();
    let from_base: u32 = (&num_str[idx+1..num_str.len()-1])
                                    .parse()
                                    .unwrap();
    let num_str = &num_str[..idx];
    let mut sum: u32 = 0;

    for c in num_str.chars() {
        assert!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'));

        sum *= from_base;
        let part = if c >= 'a' {c as u8 - 'a' as u8 + 10} else {c as u8 - '0' as u8};
        sum += part as u32;
    }
    let mut res = String::new();
    while sum != 0 {
        let remainder = (sum % to_base) as u8;
        sum = sum / to_base;
        let acii_byte = if remainder < 10 {remainder + 48u8} else {remainder + 87u8};
        res.push(char::from(acii_byte));
    }
    return res.chars().rev().collect();
}
